﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
/// <summary>
/// ctrl + k + d 快速对齐代码
/// ctrl + j 智能提示
/// ctrl + k + c 添加注释
/// ctrl + k + u 取消注释
/// </summary>
namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {

            // 条件语句
            #region if 条件语句
            int a = 20;
            if (a > 0 && a < 18)
            {
                Console.WriteLine("未成年");
                
            }
            else if (a >= 18 && a < 50)
            {
                Console.WriteLine("成年了");
            }
            else if (a > 50 && a < 100)
            {
                Console.WriteLine("老年了");
            }
            else
            {
                Console.WriteLine("老死了");
            }
            #endregion

            #region do...while 循环语句
            int b = 20;
            do
            {
                Console.WriteLine("h" + b);
                b--;
            } while (b > 0);
            #endregion

            #region sum 循环求和
            int sum = 0;
            for (int i = 0; i <= 100; i++)
            {
                sum += i;
            }
            Console.WriteLine(sum);
            #endregion

            Console.WriteLine("--------------------------");

            #region while 循环
            int c = 10;

            while (c > 0)
            {
                Console.WriteLine(c);
                c--;
            }
            #endregion

            Console.WriteLine("--------------------------");

            #region switch 条件分支
            int s = 2;

            switch (s)
            {
                case 1:
                    Console.WriteLine("执行方案一");
                    break;

                case 2:
                    Console.WriteLine("执行方案二");
                    break;

                default:
                    Console.WriteLine("没有满足的条件，最后就走这里");
                    break;
            }
            #endregion



            for(int i = 1; i <= 9; i++)
            {
                for(int j = 1; j <= i; j++)
                {
                    Console.Write("{0}*{1}={2} ",i,j,i*j);
                }
                Console.WriteLine(" ");
            }


            // 三元表达式

            int xx = 100;

            bool bb = xx > 10 ? true : false;

            Console.WriteLine(bb);



            Console.ReadKey();
        }
    }
}
